<SCRIPT type="text/javascript">
	function pannelMgr(idflag){
		$(".nav_tapWrap li").attr("class","nav_tapIthems");
		$("#"+idflag+"_bnt").attr("class","nav_tapIthems cur");
		$("#mainDiv>div").css("display","none");
		$("#"+idflag+"_div").css("display","block");
	}
	function repeatMgr(){
		if($("#isRepeat").is(":checked")){
			$("#repeatJustTime").attr("disabled",false);
			$("#repeatSpace").attr("disabled",false);
		}else{
			$("#repeatJustTime").attr("disabled",true);
			$("#repeatSpace").attr("disabled",true);
		}
	}
	function runSpaceMgr(){
		$("input[name='runDates']").attr("checked",false);
		var runType = $("input[name='runCycle']:checked").val();
		if(runType=="day"){
			$("#run_space_tr").css("display","block");
			$("#run_time_tr").css("display","none");
			$("#space_unit").html("天");
		}else if(runType=="week"){
			$("#run_space_tr").css("display","block");
			$("#run_time_tr").css("display","block");
			$("#runWeekTime_div").css("display","block");
			$("#runMonthTime_div").css("display","none");
			$("#space_unit").html("周");
		}else{
			$("#run_space_tr").css("display","none");
			$("#run_time_tr").css("display","block");
			$("#runMonthTime_div").css("display","block");
			$("#runWeekTime_div").css("display","none");
			
		}
	}
	
	function openUserGroup(){
		var userDialog = art.dialog({
		    title: '选择用户',
		    id:'selUserGroup',
		    content: '<div id ="userDialog" class="conTop" style="padding:0;margin:0"><img src="/assets/images/loading.png" width="35" height="35" alt=""><h2>页面正在载入，请稍候......</h2></div>',
		    width: 350,
		    padding:'0',
		    initialize: function () {
		    	var currentDialog = this;
				$.ajax({
					url:"/${orgi}/user/report/${tabid}/organ/selUser.html",
					cache:false,
					success: function(data){
						$("#userDialog").empty().html(data);
						//userDialog.content(data);
						userDialog._reset();
					},
					error:  function(xhr, type, s){	
						if(xhr.getResponseHeader("emsg")){
							art.alert(xhr.getResponseHeader("emsg"));
						}
					}
				}).done(function(){
				});
		    	//loadURL("/${orgi}/user/report/${tabid}/role/selUser.html" , "#tempdiv" , function(){} );
		    }
		});
	}
	
	function selUserGroupclose(){
		var s=$("#emails").val();
		$('input[name="userid"]:checked').each(function(){
			if(s.indexOf($(this).val()) !=-1){
			}else{
				if(s != ""){
					s+='\r';
				}
				if(s.indexOf($(this).attr('user_email'))<0){
					s+=$(this).attr('user_email');
				}
			}		    
		});
		$("#emails").val(s);
		var dialog = art.dialog({id: 'selUserGroup',title: false});
		dialog.close();
	}
	function submitPropertiesForm(){
		$("#propertiesForm").valid();
		if($("input[class*='error']").length==0&&$("#task_name").val().length>=3){
			$("#propertiesForm").submit()
		}else{
			pannelMgr("basemsg");
			$("#propertiesForm").valid();
		}
		
	}
	function showEmailDetail(){
	if($("input[name='runTypes']:checked").length>0){
		$("#emailDetailDiv").css("display","");
	}else{
		$("#emailDetailDiv").css("display","none");
	}
}
</SCRIPT>

<div class="artCon" style="top: 17px; margin-left: 0px;">
	<div class="middleArt">
	<form method="post" data-toggle="form" action="/${orgi}/user/report/${tabid}/${location!''}/taskaddo.html" id="propertiesForm" class="form-horizontal">
		<div class="artMain">
			<div class="rs_layout_center">
				<div class="rs_layout">
				
					<div class="rs_layout_top">
						<ul class="nav_tapWrap">
							<li id="basemsg_bnt"  onclick="pannelMgr('basemsg')" class="nav_tapIthems cur">基本信息</li>
							<li id="time_bnt" onclick="pannelMgr('time')" class="nav_tapIthems">执行时间</li>
							<li id="set_bnt" onclick="pannelMgr('set')" class="nav_tapIthems">任务配置</li>
							
						</ul>
					</div>
					<div class="rs_layout_center">
						<div id="mainDiv" style="width:100%; height:100%; overflow:auto">
							<div id="basemsg_div" style="padding:10px;">
								<table class="data_table_1">
									<tbody><tr>
										<th>任务名称：</th>
										<td><input id="task_name" type="text" value="${name!''}_任务计划" class="span2 required" minlength="3" data-message="任务名称不能为空，请填写后提交" required name="name" style="margin-left:0px;">
											<i class="inputip">*</i>
										</td>
										
										<!-- <th>联系人：</th>
										<td><input type="text" value="${user.username!''}" class="span2" name="username"></td> -->
										<td style="text-align:right;"><a href="javascript:openUserGroup()" style="margin-right:0px;" title="选择任务的收件人"><i class="icons_tablelist_user"></i></td>
									</tr>
									<tr>
										<th>收件人：</th>
										<td colspan="3" ><textarea rows="10" cols="30" id="emails" style="width:98%; height:80px; resize:none;" name="emails" ></textarea>
										</br><span style="font-size: 12px;">提示：多个邮箱之间用“Enter”分隔开。</span>
										</td>
									</tr>
									<tr >
										<th >已选报表：</th>
										<td colspan="3" style="padding-top: 10px">
											<div class="tableScrollWrap" style="height: 100px;">
												 <table class="table_style_1 table-bordered">
													<#if reports??>
													<thead>
														<tr>
															<th style="width:20px;">&nbsp;</th>
															<th style="width:70%">名称</th>
															<th>创建时间</th>
														</tr>
													</thead>
													<tbody>
														<#list reports as report>
														<tr>
															<td style="height:20px !important;width:20px;"><input checked="checked" value="${report.id}" type="checkbox" name="reportids"/> </td>
															<td style="height:20px !important;width:80%">${report.reportpackage!'/'}<#if report.reportpackage??&&report.reportpackage==''></#if>/${report.name!''}</td>
															<td nowrap="nowrap" style="height:20px !important;">${report.createtime!''}</td>
														</tr>
														</#list>
													</tbody>
													</#if>
												</table>
											</div>
										</td>
									</tr>
								</tbody></table>
							</div>
							<div id="time_div" style="padding:10px;display: none">
								<table class="data_table_1">
									<tbody>
									<tr>
										<th valign="top" style="vertical-align: top;padding-top: 10px;">类型：</th>
										<td colspan="3" >
											<label ><input onclick="runSpaceMgr()" name="runCycle" value="day" checked="checked" type="radio"/>每天</label>
											<label ><input onclick="runSpaceMgr()" name="runCycle" value="week" type="radio"/>每周</label>
											<label ><input onclick="runSpaceMgr()" name="runCycle" value="month" type="radio"/>每月</label>
										</td>
									</tr>
									
									<tr>
										<th valign="top" style="vertical-align: top;padding-top: 10px;">设置：</th>
										<td colspan="3" style="border: solid 1px #EEE;padding-left: 20px;">
											<table id="run_space_tr" class="data_table_1">
												<tbody>
													<tr>
														<th>运行间隔：</th>
														<td colspan="3" >
															<input name="runSpace" value="1" type="text">
																<span id="space_unit">天</span>
														</td>
													</tr>
												</tbody>
											</table>
											<table  id="run_time_tr" style="display: none;" class="data_table_1">
												<tbody>
													<tr>
														<th style="vertical-align: top;padding-top: 10px">于：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
														<td colspan="3" >
															<div id="runWeekTime_div" style="width: 100%">
																<label><input name="runDates" value="2" type="checkbox"/>周一</label>
																<label><input name="runDates" value="3" type="checkbox"/>周二</label>
																<label><input name="runDates" value="4" type="checkbox"/>周三</label>
																<label><input name="runDates" value="5" type="checkbox"/>周四</label>
																<label><input name="runDates" value="6" type="checkbox"/>周五</label>
																<label><input name="runDates" value="7" type="checkbox"/>周六</label>
																<label><input name="runDates" value="1" type="checkbox"/>周日</label>
															</div>
															<div id="runMonthTime_div"  style="width: 100%">
																<select name="runBeginDate">
																<#list 1..31 as a>
																<option value="${a}">${a}</option>
																</#list>
																</select>日<br/>
																<#list 1..12 as a>
																<label><input name="runDates" value="${a}" type="checkbox"/>${a}月</label>
																</#list>
															</div>
														</td>
													</tr>
												</tbody>
											</table>
											
											<table class="data_table_1">
												<tbody>
													<tr>
														<th>开始时间：</th>
														<td colspan="3" >
															<select name="runBeginHour">
																<#list 0..23 as a>
																<option value="${a}"><#if a<10>0</#if>${a}</option>
																</#list>
															</select>：
															<select name="runBeginMinute">
																<#list 0..59 as a>
																<option value="${a}"><#if a<10>0</#if>${a}</option>
																</#list>
															</select>：
															<select name="runBeginSecond">
																<#list 0..59 as a>
																<option value="${a}"><#if a<10>0</#if>${a}</option>
																</#list>
															</select>
														</td>
													</tr>
													<tr>
														<th colspan="4"><label><input onclick="repeatMgr()" id="isRepeat" name="isRepeat" value="1" type="checkbox"/>在该日内重复 </label></th>
													</tr>
													<tr>
														<th>间隔：</th>
														<td colspan="3" >
															<input disabled="disabled" id="repeatSpace" name="repeatSpace" value="5" type="text">分钟
														</td>
													</tr>
													<tr>
														<th>持续时间：</th>
														<td colspan="3" >
															<input disabled="disabled" id="repeatJustTime" name="repeatJustTime" value="1440" type="text">分钟
														</td>
													</tr>
												</tbody>
											</table>
										</td>
									</tr>
									
								</tbody></table>
							</div>
							<div id="set_div" style="padding:10px;display: none">
														
								<table class="data_table_1">
									<tbody><tr>
										<th valign="top" style="vertical-align: top;padding-top: 20px;">设置：</th>
										<td>
											<div style="display: inline-flex">
											<label><input name="formats" value="cache" id="formatscache" type="checkbox"/>缓存</label>
											<label><input name="formats" value="excel" id="formatsexcel" type="checkbox"/>EXCEL</label>
											<label><input name="formats" id="formatscsv" value="csv" type="checkbox"/>CSV</label>
											<label><input name="formats" id="formatshtml" value="html" type="checkbox"/>HTML</label>
											</div>
											
										</td>
										<th style="vertical-align: top;padding-top: 20px;">优先级：</th>
										<td style="vertical-align: top;padding-top: 10px;">
											<select name="priority">
												<option value="1">1</option>
												<option value="2">2</option>
												<option value="3" selected="selected">3</option>
												<option value="4">4</option>
												<option value="5">5</option> 
											</select>
										</td>
									</tr>
									
									<tr>
										<th rowspan="2" valign="top">执行方式：</th>
										<td style="padding-top: 30px;" colspan="3">
											<label><input name="runTypes" onclick="showEmailDetail()" value="email" type="checkbox"/>发送Email</label>
											<select name="emailType"><option value="appendix">附件发送</option><option value="text">正文发送</option></select>
											<div id="emailDetailDiv" style="display:none; margin-left: 40px;margin-top:10px;width: 100%;">
												<div style="width: 100%">邮件标题:<input name="emailTitle" value="" type="text"/></div>
												<div style="margin-top:10px;vertical-align: middle;">邮件描述:<textarea name="emailContent" style="resize:none; width: 300px;height: 50px;"></textarea> </div>
											</div>
										</td>
									</tr>
									<tr>
										<td colspan="3">
											<label><input name="runTypes" value="save" type="checkbox"/>保存报表</label>
										</td>
									</tr>
									
								</tbody></table>
							</div>
						</div>
						
					</div>
					
				</div>
			</div>
			<div class="bottomBg">
				<div class="btnWrap">
					<input type="button" onclick="submitPropertiesForm()" class="subButtonStyle" value="确认"/>
					<input type="button" onclick="closeR3ArtDialog()" class="cancelButtonStyle" value="取消"/>
				</div>
			</div>
		</div>
		</form>
	 </div>
</div>